/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('cmdb', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AppGroupAddToCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
  value?: long(name='value'),
}

model AppGroupAddToCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: AppGroupAddToCMDBResponseBody(name='body'),
}

async function appGroupAddToCMDB(): AppGroupAddToCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return appGroupAddToCMDBWithOptions(headers, runtime);
}

async function appGroupAddToCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): AppGroupAddToCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'AppGroupAddToCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/app_group/insert`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model AppGroupUpdateFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model AppGroupUpdateFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: AppGroupUpdateFromCMDBResponseBody(name='body'),
}

async function appGroupUpdateFromCMDB(): AppGroupUpdateFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return appGroupUpdateFromCMDBWithOptions(headers, runtime);
}

async function appGroupUpdateFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): AppGroupUpdateFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'AppGroupUpdateFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/app_group/update`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model CmdbCommonPostAPIRequest {
  account?: string(name='Account', description='account'),
  appName?: string(name='AppName', description='appName'),
  method?: string(name='Method', description='method'),
  param?: string(name='Param', description='param'),
  signature?: string(name='Signature', description='signature'),
  timestamp?: long(name='Timestamp', description='timestamp'),
}

model CmdbCommonPostAPIResponseBody = {
  allowRetry?: boolean(name='AllowRetry', description='allowRetry'),
  cc?: int32(name='Cc', description='cc'),
  errorCode?: int32(name='ErrorCode', description='errorCode'),
  errorCodeMsg?: string(name='ErrorCodeMsg', description='errorCodeMsg'),
  errorMessage?: string(name='ErrorMessage', description='errorMessage'),
  exceptionName?: string(name='ExceptionName', description='exceptionName'),
  success?: boolean(name='Success', description='success'),
  value?: long(name='Value', description='value'),
}

model CmdbCommonPostAPIResponse = {
  headers: map[string]string(name='headers'),
  body: CmdbCommonPostAPIResponseBody(name='body'),
}

async function cmdbCommonPostAPI(request: CmdbCommonPostAPIRequest): CmdbCommonPostAPIResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return cmdbCommonPostAPIWithOptions(request, headers, runtime);
}

async function cmdbCommonPostAPIWithOptions(request: CmdbCommonPostAPIRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CmdbCommonPostAPIResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.appName)) {
    query['AppName'] = request.appName;
  }
  if (!Util.isUnset(request.method)) {
    query['Method'] = request.method;
  }
  if (!Util.isUnset(request.param)) {
    query['Param'] = request.param;
  }
  if (!Util.isUnset(request.signature)) {
    query['Signature'] = request.signature;
  }
  if (!Util.isUnset(request.timestamp)) {
    query['Timestamp'] = request.timestamp;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CmdbCommonPostAPI',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/api/common-post`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model CreatePodFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model CreatePodFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: CreatePodFromCMDBResponseBody(name='body'),
}

async function createPodFromCMDB(): CreatePodFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createPodFromCMDBWithOptions(headers, runtime);
}

async function createPodFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): CreatePodFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'CreatePodFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTP',
    pathname = `/openapi/device/vm/add`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model DeletePodFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model DeletePodFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: DeletePodFromCMDBResponseBody(name='body'),
}

async function deletePodFromCMDB(): DeletePodFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deletePodFromCMDBWithOptions(headers, runtime);
}

async function deletePodFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): DeletePodFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeletePodFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTP',
    pathname = `/openapi/device/vm/delete`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemAddToCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
  value?: [ long ](name='value'),
}

model ItemAddToCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemAddToCMDBResponseBody(name='body'),
}

async function itemAddToCMDB(): ItemAddToCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemAddToCMDBWithOptions(headers, runtime);
}

async function itemAddToCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemAddToCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemAddToCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/v2/item/add`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemBatchAddToCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
  value?: [ long ](name='value'),
}

model ItemBatchAddToCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemBatchAddToCMDBResponseBody(name='body'),
}

async function itemBatchAddToCMDB(): ItemBatchAddToCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemBatchAddToCMDBWithOptions(headers, runtime);
}

async function itemBatchAddToCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemBatchAddToCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemBatchAddToCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/item/batch_add`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemBatchDeleteFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model ItemBatchDeleteFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemBatchDeleteFromCMDBResponseBody(name='body'),
}

async function itemBatchDeleteFromCMDB(): ItemBatchDeleteFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemBatchDeleteFromCMDBWithOptions(headers, runtime);
}

async function itemBatchDeleteFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemBatchDeleteFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemBatchDeleteFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/item/batch_delete`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemBatchUpdateFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model ItemBatchUpdateFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemBatchUpdateFromCMDBResponseBody(name='body'),
}

async function itemBatchUpdateFromCMDB(): ItemBatchUpdateFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemBatchUpdateFromCMDBWithOptions(headers, runtime);
}

async function itemBatchUpdateFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemBatchUpdateFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemBatchUpdateFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/item/batch_update`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemDeleteFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model ItemDeleteFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemDeleteFromCMDBResponseBody(name='body'),
}

async function itemDeleteFromCMDB(): ItemDeleteFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemDeleteFromCMDBWithOptions(headers, runtime);
}

async function itemDeleteFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemDeleteFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemDeleteFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/v2/item/delete`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ItemUpdateFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model ItemUpdateFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: ItemUpdateFromCMDBResponseBody(name='body'),
}

async function itemUpdateFromCMDB(): ItemUpdateFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return itemUpdateFromCMDBWithOptions(headers, runtime);
}

async function itemUpdateFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ItemUpdateFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ItemUpdateFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTPS',
    pathname = `/v2/item/update`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model QueryPodFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
  value?: {
    hasMore?: boolean(name='hasMore'),
    itemList?: {
      item?: [  map[string]any ](name='item')
    }(name='itemList'),
    totalCount?: int32(name='totalCount'),
  }(name='value'),
}

model QueryPodFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: QueryPodFromCMDBResponseBody(name='body'),
}

async function queryPodFromCMDB(): QueryPodFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return queryPodFromCMDBWithOptions(headers, runtime);
}

async function queryPodFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): QueryPodFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'QueryPodFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTP',
    pathname = `/item/query`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model UpdatePodFromCMDBResponseBody = {
  errorCode?: int32(name='errorCode'),
  errorMessage?: string(name='errorMessage'),
  success?: boolean(name='success'),
}

model UpdatePodFromCMDBResponse = {
  headers: map[string]string(name='headers'),
  body: UpdatePodFromCMDBResponseBody(name='body'),
}

async function updatePodFromCMDB(): UpdatePodFromCMDBResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updatePodFromCMDBWithOptions(headers, runtime);
}

async function updatePodFromCMDBWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): UpdatePodFromCMDBResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'UpdatePodFromCMDB',
    version = '2019-05-15',
    protocol = 'HTTP',
    pathname = `/openapi/device/server/update`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

